<script type="text/javascript">
	$(function(){
		EBCMS.{$namespace}.getconfig = function getconfig(p){
			EBCMS.CORE.get({
				url:'{:U('Admin/Config/save')}',
				queryParams:p,
				target:'#lgModal .modal-content',
			});
		};
		EBCMS.{$namespace}.getconf = function getconf(p){
			EBCMS.CORE.get({
				url:'{:U('Admin/Conf/save')}',
				queryParams:p,
				target:'#lgModal .modal-content',
			});
		};

		EBCMS.{$namespace}.queryParams = {
			// page:1,
			// rows:20,
			sort:'id',
			order:'desc',
			__module:'Admin',
			__model:'Conf',
			__where:{
				category_id:['eq',17]
			}
		};
		EBCMS.{$namespace}.refresh = function refresh(p){
			if (p) {
				$.each(p, function(index, val) {
					if (typeof val == 'object') {
						EBCMS.{$namespace}.queryParams[index] = $.extend(EBCMS.{$namespace}.queryParams[index], p[index]);
						delete p[index];
					};
				});
				$.extend(EBCMS.{$namespace}.queryParams, p);
			};
			EBCMS.CORE.api({
				queryParams:EBCMS.{$namespace}.queryParams,
				tpl:'{$namespace}-table',
				target:'#{$namespace}_table',
				compileAfter:function(p){
					EBCMS.FN.renderPage({
						namespace:'{$namespace}',
						total:p.data.total,
						filter:{
							lock:true,
							status:true,
							// sort:{
							// 	filters:{id:'id',update_time:'更新时间',sort:'权重',create_time:'创建时间'}
							// },
							// order:true,
							// rows:true,
						},
					});
				},
			});
		};
		EBCMS.{$namespace}.addconf = function addconf(){
			EBCMS.CORE.get({
				url:'{:U('Admin/Conf/addcustom')}',
				queryParams:{},
				target:'#lgModal .modal-content',
			});
		};
		EBCMS.{$namespace}.saveconf = function saveconf(id){
			EBCMS.CORE.get({
				url:'{:U('Admin/Conf/savecustom')}',
				queryParams:{
					id:id
				},
				target:'#lgModal .modal-content',
			});
		};
		EBCMS.{$namespace}.refresh();
	});
</script>
<div class="panel">
	<div class="panel-body">
		<button class="btn btn-danger btn-xs pull-right" onclick="EBCMS.ACT.ajaxPost({url:'{:U('Config/build')}'});">更新配置</button>
		<p class="text-danger">编辑配置后，配置不会生效，需要更新配置方可生效！</p>
		<div class="well well-sm">系统配置</div>
		<!-- <div onclick="EBCMS.{$namespace}.getconfig({category_id:'12'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">数据库</span>
		</div> -->
		<!-- <div onclick="EBCMS.{$namespace}.getconfig({category_id:'16'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">数据备份</span>
		</div> -->
		<div onclick="EBCMS.{$namespace}.getconf({category_id:'12'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">验证码</span>
		</div>
		<div onclick="EBCMS.{$namespace}.getconfig({category_id:'22'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">权限认证</span>
		</div>
		<!-- <div onclick="EBCMS.{$namespace}.getconfig({category_id:'23'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">邮箱配置</span>
		</div> -->
		<!-- <div onclick="EBCMS.{$namespace}.getconfig({category_id:'25'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">验证开关</span>
		</div> -->
		<!-- <div onclick="EBCMS.{$namespace}.getconf({category_id:'16'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">消息模板</span>
		</div> -->
		<!-- <div onclick="EBCMS.{$namespace}.getconfig({category_id:'15'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">表单令牌</span>
		</div> -->
		<div onclick="EBCMS.{$namespace}.getconf({category_id:'3'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">上传配置</span>
		</div>
		<!-- <div onclick="EBCMS.{$namespace}.getconf({category_id:'2'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">编辑器</span>
		</div> -->
		<div onclick="EBCMS.{$namespace}.getconfig({category_id:'21'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">前台配置</span>
		</div>
		<div onclick="EBCMS.{$namespace}.getconfig({pid:'186'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">新闻模块</span>
		</div>
		<div onclick="EBCMS.{$namespace}.getconfig({pid:'188'});" class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
			<span style="display:block;width:100%;height:100px;background:#FF630E;line-height:100px;color:#fff;font-size:30px;text-align:center;">留言模块</span>
		</div>
	</div>
	<div class="panel-body">
		<div class="well well-sm"><button class=" pull-right btn btn-danger btn-xs" onclick="EBCMS.{$namespace}.addconf();">添加</button>自定义配置 前台通过标签 <code>&#123;:mycfg('键')&#125;</code> 调用，如果有html代码，请使用 <code>&#123;:htmlspecialchars_decode(mycfg('键'))&#125;</code> 调用</div>
		<div>
			<div class="box" id="{$namespace}_table"></div>
		</div>
		<hr>
		<div class="footer-page" id="{$namespace}_page"></div>
	</div>
</div>

<script id="{$namespace}-table" type="text/html">
	{{each rows as v n}}
		<div class="media articlelist">
			<div class="media-left">
				<div style="width:48px;">
					<div class="btn-group-vertical btn-group-sm" role="group" aria-label="...">
						{{if access(0,'{$namespace}','lock')}}
							{{if v.locked==1}}
							<a class="btn btn-info" href="javascript:EBCMS.ACT.lock('{:U('Conf/lock')}','{{v.id}}','0','{$namespace}');">已锁</a>
							{{else}}
							<a class="btn btn-info" href="javascript:EBCMS.ACT.lock('{:U('Conf/lock')}','{{v.id}}','1','{$namespace}');">未锁</a>
							{{/if}}
						{{/if}}
						{{if access(v.locked,'{$namespace}','status')}}
							{{if v.status==1}}
							<a class="btn btn-info" href="javascript:EBCMS.ACT.status('{:U('Conf/status')}','{{v.id}}','0','{$namespace}');">已审</a>
							{{else}}
							<a class="btn btn-info" href="javascript:EBCMS.ACT.status('{:U('Conf/status')}','{{v.id}}','1','{$namespace}');">未审</a>
							{{/if}}
						{{/if}}
						{{if access(v.locked,'{$namespace}','save')}}
						<a class="btn btn-info" href="javascript:EBCMS.{$namespace}.saveconf('{{v.id}}');">编辑</a>
						{{/if}}
						{{if access(v.locked,'{$namespace}','delete')}}
						<a class="btn btn-info" href="javascript:EBCMS.ACT.del('{:U('Conf/delete')}','{{v.id}}','{$namespace}');">删除</a>
						{{/if}}
					</div>
				</div>
			</div>
			<div class="media-body">
				<h4 class="media-heading"><code>&#123;:mycfg('{{v.name}}')&#125;</code></h4>
				<div><pre>{{v.value}}</pre></div>
				<footer><em>备注：{{v.instruction}}</em></footer>
			</div>
		</div>
	{{/each}}
</script>